<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: container   Dialog.js  (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
</head>

<body id="yahoo-com">
<div id="doc3" class="yui-t2">

	<div id="hd">
        <h1>Yahoo! UI Library</h1>
        <h3>Container&nbsp; <span class="subtitle">2.2.2</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_container.html">container</a>
                
                 &gt; Dialog.js (source view) 
            </p>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">

                    <div id="srcout">
<div class="highlight" ><pre><span class="c">/**</span>
<span class="c">* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.</span>
<span class="c">* @namespace YAHOO.widget</span>
<span class="c">* @class Dialog</span>
<span class="c">* @extends YAHOO.widget.Panel</span>
<span class="c">* @constructor</span>
<span class="c">* @param {String}	el	The element ID representing the Dialog &lt;em&gt;OR&lt;/em&gt;</span>
<span class="c">* @param {HTMLElement}	el	The element representing the Dialog</span>
<span class="c">* @param {Object}	userConfig	The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">userConfig</span><span class="o">)</span> <span class="o">{</span>
	<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">el</span><span class="o">,</span> <span class="nx">userConfig</span><span class="o">);</span>
<span class="o">};</span>

<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">extend</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Panel</span><span class="o">);</span>

<span class="c">/**</span>
<span class="c">* Constant representing the default CSS class used for a Dialog</span>
<span class="c">* @property YAHOO.widget.Dialog.CSS_DIALOG</span>
<span class="c">* @static</span>
<span class="c">* @final</span>
<span class="c">* @type String</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">CSS_DIALOG</span> <span class="o">=</span> <span class="s2">&quot;yui-dialog&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c">* Constant representing the name of the Dialog&#39;s events</span>
<span class="c">* @property YAHOO.widget.Dialog._EVENT_TYPES</span>
<span class="c">* @private</span>
<span class="c">* @final</span>
<span class="c">* @type Object</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">_EVENT_TYPES</span> <span class="o">=</span> <span class="o">{</span>

	<span class="s2">&quot;BEFORE_SUBMIT&quot;</span><span class="o">:</span> <span class="s2">&quot;beforeSubmit&quot;</span><span class="o">,</span>
	<span class="s2">&quot;SUBMIT&quot;</span><span class="o">:</span> <span class="s2">&quot;submit&quot;</span><span class="o">,</span>
	<span class="s2">&quot;MANUAL_SUBMIT&quot;</span><span class="o">:</span> <span class="s2">&quot;manualSubmit&quot;</span><span class="o">,</span>
	<span class="s2">&quot;ASYNC_SUBMIT&quot;</span><span class="o">:</span> <span class="s2">&quot;asyncSubmit&quot;</span><span class="o">,</span>
	<span class="s2">&quot;FORM_SUBMIT&quot;</span><span class="o">:</span> <span class="s2">&quot;formSubmit&quot;</span><span class="o">,</span>
	<span class="s2">&quot;CANCEL&quot;</span><span class="o">:</span> <span class="s2">&quot;cancel&quot;</span>

<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Constant representing the Dialog&#39;s configuration properties</span>
<span class="c">* @property YAHOO.widget.Dialog._DEFAULT_CONFIG</span>
<span class="c">* @private</span>
<span class="c">* @final</span>
<span class="c">* @type Object</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">_DEFAULT_CONFIG</span> <span class="o">=</span> <span class="o">{</span>

	<span class="s2">&quot;POST_METHOD&quot;</span><span class="o">:</span> <span class="o">{</span> 
	   <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;postmethod&quot;</span><span class="o">,</span> 
	   <span class="nx">value</span><span class="o">:</span> <span class="s2">&quot;async&quot;</span> 
    <span class="o">},</span>

	<span class="s2">&quot;BUTTONS&quot;</span><span class="o">:</span> <span class="o">{</span> 
	   <span class="nx">key</span><span class="o">:</span> <span class="s2">&quot;buttons&quot;</span><span class="o">,</span> 
	   <span class="nx">value</span><span class="o">:</span> <span class="s2">&quot;none&quot;</span> 
    <span class="o">}</span>

<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Initializes the class&#39;s configurable properties which can be changed using the Dialog&#39;s Config object (cfg).</span>
<span class="c">* @method initDefaultConfig</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">initDefaultConfig</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">initDefaultConfig</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>

	<span class="c">/**</span>
<span class="c">	* The internally maintained callback object for use with the Connection utility</span>
<span class="c">	* @property callback</span>
<span class="c">	* @type Object</span>
<span class="c">	*/</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">callback</span> <span class="o">=</span> <span class="o">{</span>
		<span class="c">/**</span>
<span class="c">		* The function to execute upon success of the Connection submission</span>
<span class="c">		* @property callback.success</span>
<span class="c">		* @type Function</span>
<span class="c">		*/</span>
		<span class="nx">success</span> <span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
		<span class="c">/**</span>
<span class="c">		* The function to execute upon failure of the Connection submission</span>
<span class="c">		* @property callback.failure</span>
<span class="c">		* @type Function</span>
<span class="c">		*/</span>
		<span class="nx">failure</span> <span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
		<span class="c">/**</span>
<span class="c">		* The arbitraty argument or arguments to pass to the Connection callback functions</span>
<span class="c">		* @property callback.argument</span>
<span class="c">		* @type Object</span>
<span class="c">		*/</span>
		<span class="nx">argument</span><span class="o">:</span> <span class="kc">null</span>
	<span class="o">};</span>

	<span class="c">// Add form dialog config properties //</span>
<span class="c"></span>	
	<span class="k">var</span> <span class="nx">DEFAULT_CONFIG</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">_DEFAULT_CONFIG</span><span class="o">;</span>
	
	<span class="c">/**</span>
<span class="c">	* The method to use for posting the Dialog&#39;s form. Possible values are &quot;async&quot;, &quot;form&quot;, and &quot;manual&quot;.</span>
<span class="c">	* @config postmethod</span>
<span class="c">	* @type String</span>
<span class="c">	* @default async</span>
<span class="c">	*/</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
	           <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">POST_METHOD</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span> 
                <span class="o">{</span>
                    <span class="nx">handler</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">configPostMethod</span><span class="o">,</span> 
                    <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">POST_METHOD</span><span class="o">.</span><span class="nx">value</span><span class="o">,</span> 
                    <span class="nx">validator</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">if</span> <span class="o">(</span><span class="nx">val</span> <span class="o">!=</span> <span class="s2">&quot;form&quot;</span> <span class="o">&amp;&amp;</span> <span class="nx">val</span> <span class="o">!=</span> <span class="s2">&quot;async&quot;</span> <span class="o">&amp;&amp;</span> <span class="nx">val</span> <span class="o">!=</span> <span class="s2">&quot;none&quot;</span> <span class="o">&amp;&amp;</span> <span class="nx">val</span> <span class="o">!=</span> <span class="s2">&quot;manual&quot;</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
                        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
                            <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="o">}</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">);</span>

	<span class="c">/**</span>
<span class="c">	* Object literal(s) defining the buttons for the Dialog&#39;s footer.</span>
<span class="c">	* @config buttons</span>
<span class="c">	* @type Object[]</span>
<span class="c">	* @default &quot;none&quot;</span>
<span class="c">	*/</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">addProperty</span><span class="o">(</span>
	           <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">BUTTONS</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span>
	           <span class="o">{</span>
	               <span class="nx">handler</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">configButtons</span><span class="o">,</span>
	               <span class="nx">value</span><span class="o">:</span> <span class="nx">DEFAULT_CONFIG</span><span class="o">.</span><span class="nx">BUTTONS</span><span class="o">.</span><span class="nx">value</span>
               <span class="o">}</span>
           <span class="o">);</span>	
	
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class.</span>
<span class="c">* @method initEvents</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">initEvents</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">initEvents</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>

    <span class="k">var</span> <span class="nx">EVENT_TYPES</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">_EVENT_TYPES</span><span class="o">;</span>

	<span class="c">/**</span>
<span class="c">	* CustomEvent fired prior to submission</span>
<span class="c">	* @event beforeSumitEvent</span>
<span class="c">	*/</span>	
	<span class="k">this</span><span class="o">.</span><span class="nx">beforeSubmitEvent</span>	<span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">BEFORE_SUBMIT</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
	
	<span class="c">/**</span>
<span class="c">	* CustomEvent fired after submission</span>
<span class="c">	* @event submitEvent</span>
<span class="c">	*/</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">submitEvent</span>		<span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">SUBMIT</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

	<span class="c">/**</span>
<span class="c">	* CustomEvent fired prior to manual submission</span>
<span class="c">	* @event manualSubmitEvent</span>
<span class="c">	*/</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">manualSubmitEvent</span>	<span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">MANUAL_SUBMIT</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

	<span class="c">/**</span>
<span class="c">	* CustomEvent fired prior to asynchronous submission</span>
<span class="c">	* @event asyncSubmitEvent</span>
<span class="c">	*/</span>	
	<span class="k">this</span><span class="o">.</span><span class="nx">asyncSubmitEvent</span>	<span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">ASYNC_SUBMIT</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

	<span class="c">/**</span>
<span class="c">	* CustomEvent fired prior to form-based submission</span>
<span class="c">	* @event formSubmitEvent</span>
<span class="c">	*/</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">formSubmitEvent</span>	<span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">FORM_SUBMIT</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

	<span class="c">/**</span>
<span class="c">	* CustomEvent fired after cancel</span>
<span class="c">	* @event cancelEvent</span>
<span class="c">	*/</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">cancelEvent</span>		<span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">CustomEvent</span><span class="o">(</span><span class="nx">EVENT_TYPES</span><span class="o">.</span><span class="nx">CANCEL</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and  sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.</span>
<span class="c">* @method init</span>
<span class="c">* @param {String}	el	The element ID representing the Dialog &lt;em&gt;OR&lt;/em&gt;</span>
<span class="c">* @param {HTMLElement}	el	The element representing the Dialog</span>
<span class="c">* @param {Object}	userConfig	The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">init</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">userConfig</span><span class="o">)</span> <span class="o">{</span>
	<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">init</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">el</span><span class="c">/*, userConfig*/</span><span class="o">);</span>  <span class="c">// Note that we don&#39;t pass the user config in here yet because we only want it executed once, at the lowest subclass level</span>
<span class="c"></span>
	<span class="k">this</span><span class="o">.</span><span class="nx">beforeInitEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">);</span>

	<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">CSS_DIALOG</span><span class="o">);</span>

	<span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">setProperty</span><span class="o">(</span><span class="s2">&quot;visible&quot;</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>

	<span class="k">if</span> <span class="o">(</span><span class="nx">userConfig</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">applyConfig</span><span class="o">(</span><span class="nx">userConfig</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
	<span class="o">}</span>

	<span class="k">this</span><span class="o">.</span><span class="nx">showEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">focusFirst</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">beforeHideEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">blurButtons</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

	<span class="k">this</span><span class="o">.</span><span class="nx">beforeRenderEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>
		<span class="k">var</span> <span class="nx">buttonCfg</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;buttons&quot;</span><span class="o">);</span>
		<span class="k">if</span> <span class="o">(</span><span class="nx">buttonCfg</span> <span class="o">&amp;&amp;</span> <span class="nx">buttonCfg</span> <span class="o">!=</span> <span class="s2">&quot;none&quot;</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">if</span> <span class="o">(!</span> <span class="k">this</span><span class="o">.</span><span class="nx">footer</span><span class="o">)</span> <span class="o">{</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">setFooter</span><span class="o">(</span><span class="s2">&quot;&quot;</span><span class="o">);</span>
			<span class="o">}</span>
		<span class="o">}</span>
	<span class="o">},</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

	<span class="k">this</span><span class="o">.</span><span class="nx">initEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Performs the submission of the Dialog form depending on the value of &quot;postmethod&quot; property.</span>
<span class="c">* @method doSubmit</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">doSubmit</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">var</span> <span class="nx">pm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;postmethod&quot;</span><span class="o">);</span>
	<span class="nx">switch</span> <span class="o">(</span><span class="nx">pm</span><span class="o">)</span> <span class="o">{</span>
		<span class="nx">case</span> <span class="s2">&quot;async&quot;</span><span class="o">:</span>
			<span class="k">var</span> <span class="nx">method</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">.</span><span class="nx">getAttribute</span><span class="o">(</span><span class="s2">&quot;method&quot;</span><span class="o">)</span> <span class="o">||</span> <span class="s1">&#39;POST&#39;</span><span class="o">;</span>
			<span class="nx">method</span> <span class="o">=</span> <span class="nx">method</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Connect</span><span class="o">.</span><span class="nx">setForm</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">);</span>
			<span class="k">var</span> <span class="nx">cObj</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Connect</span><span class="o">.</span><span class="nx">asyncRequest</span><span class="o">(</span><span class="nx">method</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">.</span><span class="nx">getAttribute</span><span class="o">(</span><span class="s2">&quot;action&quot;</span><span class="o">),</span> <span class="k">this</span><span class="o">.</span><span class="nx">callback</span><span class="o">);</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">asyncSubmitEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
			<span class="k">break</span><span class="o">;</span>
		<span class="nx">case</span> <span class="s2">&quot;form&quot;</span><span class="o">:</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">.</span><span class="nx">submit</span><span class="o">();</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">formSubmitEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
			<span class="k">break</span><span class="o">;</span>
		<span class="nx">case</span> <span class="s2">&quot;none&quot;</span><span class="o">:</span>
		<span class="nx">case</span> <span class="s2">&quot;manual&quot;</span><span class="o">:</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">manualSubmitEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
			<span class="k">break</span><span class="o">;</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* @method _onFormKeyDown</span>
<span class="c">* @description &quot;keydown&quot; event handler for the dialog&#39;s form.</span>
<span class="c">* @protected</span>
<span class="c">* @param {Event} p_oEvent Object representing the DOM event object passed </span>
<span class="c">* back by the event utility (YAHOO.util.Event).</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onFormKeyDown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">)</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">),</span>
        <span class="nx">nCharCode</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">p_oEvent</span><span class="o">);</span>

    <span class="k">if</span> <span class="o">(</span>
        <span class="nx">nCharCode</span> <span class="o">==</span> <span class="m">13</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">oTarget</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">&amp;&amp;</span> 
        <span class="nx">oTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span>
    <span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="nx">oTarget</span><span class="o">.</span><span class="nx">type</span><span class="o">;</span>

        <span class="k">if</span><span class="o">(</span>
            <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;text&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;password&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span> <span class="o">||</span> 
            <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span> <span class="o">||</span> <span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;file&quot;</span>
        <span class="o">)</span> <span class="o">{</span>

            <span class="c">// Fire the &quot;click&quot; event on the dialog&#39;s default button</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">defaultHtmlButton</span><span class="o">.</span><span class="nx">click</span><span class="o">();</span>
        
        <span class="o">}</span>

    <span class="o">}</span>

<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Prepares the Dialog&#39;s internal FORM object, creating one if one is not currently present.</span>
<span class="c">* @method registerForm</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">registerForm</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">var</span> <span class="nx">form</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="s2">&quot;form&quot;</span><span class="o">)[</span><span class="m">0</span><span class="o">];</span>

	<span class="k">if</span> <span class="o">(!</span> <span class="nx">form</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">var</span> <span class="nx">formHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;form name=\&quot;frm_&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s2">&quot;\&quot; action=\&quot;\&quot;&gt;&lt;/form&gt;&quot;</span><span class="o">;</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">+=</span> <span class="nx">formHTML</span><span class="o">;</span>
		<span class="nx">form</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">element</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="s2">&quot;form&quot;</span><span class="o">)[</span><span class="m">0</span><span class="o">];</span>
	<span class="o">}</span>

	<span class="k">this</span><span class="o">.</span><span class="nx">firstFormElement</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
		<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">f</span><span class="o">=</span><span class="m">0</span><span class="o">;</span><span class="nx">f</span><span class="o">&lt;</span><span class="nx">form</span><span class="o">.</span><span class="nx">elements</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span><span class="nx">f</span><span class="o">++</span> <span class="o">)</span> <span class="o">{</span>
			<span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="nx">form</span><span class="o">.</span><span class="nx">elements</span><span class="o">[</span><span class="nx">f</span><span class="o">];</span>
			<span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">focus</span> <span class="o">&amp;&amp;</span> <span class="o">!</span> <span class="nx">el</span><span class="o">.</span><span class="nx">disabled</span><span class="o">)</span> <span class="o">{</span>
				<span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">type</span> <span class="o">&amp;&amp;</span> <span class="nx">el</span><span class="o">.</span><span class="nx">type</span> <span class="o">!=</span> <span class="s2">&quot;hidden&quot;</span><span class="o">)</span> <span class="o">{</span>
					<span class="k">return</span> <span class="nx">el</span><span class="o">;</span>
				<span class="o">}</span>
			<span class="o">}</span>
		<span class="o">}</span>
		<span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
	<span class="o">}();</span>

	<span class="k">this</span><span class="o">.</span><span class="nx">lastFormElement</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
		<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">f</span><span class="o">=</span><span class="nx">form</span><span class="o">.</span><span class="nx">elements</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span><span class="nx">f</span><span class="o">&gt;=</span><span class="m">0</span><span class="o">;</span><span class="nx">f</span><span class="o">--</span> <span class="o">)</span> <span class="o">{</span>
			<span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="nx">form</span><span class="o">.</span><span class="nx">elements</span><span class="o">[</span><span class="nx">f</span><span class="o">];</span>
			<span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">focus</span> <span class="o">&amp;&amp;</span> <span class="o">!</span> <span class="nx">el</span><span class="o">.</span><span class="nx">disabled</span><span class="o">)</span> <span class="o">{</span>
				<span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">type</span> <span class="o">&amp;&amp;</span> <span class="nx">el</span><span class="o">.</span><span class="nx">type</span> <span class="o">!=</span> <span class="s2">&quot;hidden&quot;</span><span class="o">)</span> <span class="o">{</span>
					<span class="k">return</span> <span class="nx">el</span><span class="o">;</span>
				<span class="o">}</span>
			<span class="o">}</span>
		<span class="o">}</span>
		<span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
	<span class="o">}();</span>

	<span class="k">this</span><span class="o">.</span><span class="nx">form</span> <span class="o">=</span> <span class="nx">form</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">form</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">browser</span> <span class="o">==</span> <span class="s2">&quot;ie&quot;</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">browser</span> <span class="o">==</span> <span class="s2">&quot;ie7&quot;</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">browser</span> <span class="o">==</span> <span class="s2">&quot;gecko&quot;</span><span class="o">))</span> <span class="o">{</span>

        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">,</span> <span class="s2">&quot;keydown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onFormKeyDown</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    
    <span class="o">}</span>


	<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;modal&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">)</span> <span class="o">{</span>

		<span class="k">var</span> <span class="nx">me</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>

		<span class="k">var</span> <span class="nx">firstElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">firstFormElement</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">firstButton</span><span class="o">;</span>
		<span class="k">if</span> <span class="o">(</span><span class="nx">firstElement</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">preventBackTab</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">KeyListener</span><span class="o">(</span><span class="nx">firstElement</span><span class="o">,</span> <span class="o">{</span> <span class="nx">shift</span><span class="o">:</span><span class="kc">true</span><span class="o">,</span> <span class="nx">keys</span><span class="o">:</span><span class="m">9</span> <span class="o">},</span> <span class="o">{</span><span class="nx">fn</span><span class="o">:</span><span class="nx">me</span><span class="o">.</span><span class="nx">focusLast</span><span class="o">,</span> <span class="nx">scope</span><span class="o">:</span><span class="nx">me</span><span class="o">,</span> <span class="nx">correctScope</span><span class="o">:</span><span class="kc">true</span><span class="o">}</span> <span class="o">);</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">showEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">preventBackTab</span><span class="o">.</span><span class="nx">enable</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">preventBackTab</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">hideEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">preventBackTab</span><span class="o">.</span><span class="nx">disable</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">preventBackTab</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
		<span class="o">}</span>

		<span class="k">var</span> <span class="nx">lastElement</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">lastButton</span> <span class="o">||</span> <span class="k">this</span><span class="o">.</span><span class="nx">lastFormElement</span><span class="o">;</span>
		<span class="k">if</span> <span class="o">(</span><span class="nx">lastElement</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">preventTabOut</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">KeyListener</span><span class="o">(</span><span class="nx">lastElement</span><span class="o">,</span> <span class="o">{</span> <span class="nx">shift</span><span class="o">:</span><span class="kc">false</span><span class="o">,</span> <span class="nx">keys</span><span class="o">:</span><span class="m">9</span> <span class="o">},</span> <span class="o">{</span><span class="nx">fn</span><span class="o">:</span><span class="nx">me</span><span class="o">.</span><span class="nx">focusFirst</span><span class="o">,</span> <span class="nx">scope</span><span class="o">:</span><span class="nx">me</span><span class="o">,</span> <span class="nx">correctScope</span><span class="o">:</span><span class="kc">true</span><span class="o">}</span> <span class="o">);</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">showEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">preventTabOut</span><span class="o">.</span><span class="nx">enable</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">preventTabOut</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">hideEvent</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">preventTabOut</span><span class="o">.</span><span class="nx">disable</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">preventTabOut</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
		<span class="o">}</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c">* The default event handler fired when the &quot;close&quot; property is changed. The method controls the appending or hiding of the close icon at the top right of the Dialog.</span>
<span class="c">* @method configClose</span>
<span class="c">* @param {String} type	The CustomEvent type (usually the property name)</span>
<span class="c">* @param {Object[]}	args	The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.</span>
<span class="c">* @param {Object} obj	The scope object. For configuration handlers, this will usually equal the owner.</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">configClose</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">args</span><span class="o">,</span> <span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
	<span class="k">var</span> <span class="nx">val</span> <span class="o">=</span> <span class="nx">args</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>

	<span class="k">var</span> <span class="nx">doCancel</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
		<span class="nx">obj</span><span class="o">.</span><span class="nx">cancel</span><span class="o">();</span>
	<span class="o">};</span>

	<span class="k">if</span> <span class="o">(</span><span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">if</span> <span class="o">(!</span> <span class="k">this</span><span class="o">.</span><span class="nx">close</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">close</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;div&quot;</span><span class="o">);</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">close</span><span class="o">,</span> <span class="s2">&quot;container-close&quot;</span><span class="o">);</span>

			<span class="k">this</span><span class="o">.</span><span class="nx">close</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&amp;#160;&quot;</span><span class="o">;</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">innerElement</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">close</span><span class="o">);</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">close</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="nx">doCancel</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
		<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">close</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;block&quot;</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
		<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">close</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">close</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* The default event handler for the &quot;buttons&quot; configuration property</span>
<span class="c">* @method configButtons</span>
<span class="c">* @param {String} type	The CustomEvent type (usually the property name)</span>
<span class="c">* @param {Object[]}	args	The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.</span>
<span class="c">* @param {Object} obj	The scope object. For configuration handlers, this will usually equal the owner.</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">configButtons</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">args</span><span class="o">,</span> <span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
	<span class="k">var</span> <span class="nx">buttons</span> <span class="o">=</span> <span class="nx">args</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
	<span class="k">if</span> <span class="o">(</span><span class="nx">buttons</span> <span class="o">!=</span> <span class="s2">&quot;none&quot;</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">);</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span><span class="o">.</span><span class="nx">className</span> <span class="o">=</span> <span class="s2">&quot;button-group&quot;</span><span class="o">;</span>

		<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">b</span><span class="o">=</span><span class="m">0</span><span class="o">;</span><span class="nx">b</span><span class="o">&lt;</span><span class="nx">buttons</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span><span class="nx">b</span><span class="o">++)</span> <span class="o">{</span>
			<span class="k">var</span> <span class="nx">button</span> <span class="o">=</span> <span class="nx">buttons</span><span class="o">[</span><span class="nx">b</span><span class="o">];</span>

			<span class="k">var</span> <span class="nx">htmlButton</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;button&quot;</span><span class="o">);</span>
			<span class="nx">htmlButton</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">(</span><span class="s2">&quot;type&quot;</span><span class="o">,</span> <span class="s2">&quot;button&quot;</span><span class="o">);</span>

			<span class="k">if</span> <span class="o">(</span><span class="nx">button</span><span class="o">.</span><span class="nx">isDefault</span><span class="o">)</span> <span class="o">{</span>
				<span class="nx">htmlButton</span><span class="o">.</span><span class="nx">className</span> <span class="o">=</span> <span class="s2">&quot;default&quot;</span><span class="o">;</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">defaultHtmlButton</span> <span class="o">=</span> <span class="nx">htmlButton</span><span class="o">;</span>
			<span class="o">}</span>

			<span class="nx">htmlButton</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createTextNode</span><span class="o">(</span><span class="nx">button</span><span class="o">.</span><span class="nx">text</span><span class="o">));</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">htmlButton</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="nx">button</span><span class="o">.</span><span class="nx">handler</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

			<span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">htmlButton</span><span class="o">);</span>
			<span class="nx">button</span><span class="o">.</span><span class="nx">htmlButton</span> <span class="o">=</span> <span class="nx">htmlButton</span><span class="o">;</span>

			<span class="k">if</span> <span class="o">(</span><span class="nx">b</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">firstButton</span> <span class="o">=</span> <span class="nx">button</span><span class="o">.</span><span class="nx">htmlButton</span><span class="o">;</span>
			<span class="o">}</span>

			<span class="k">if</span> <span class="o">(</span><span class="nx">b</span> <span class="o">==</span> <span class="o">(</span><span class="nx">buttons</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">))</span> <span class="o">{</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">lastButton</span> <span class="o">=</span> <span class="nx">button</span><span class="o">.</span><span class="nx">htmlButton</span><span class="o">;</span>
			<span class="o">}</span>

		<span class="o">}</span>

		<span class="k">this</span><span class="o">.</span><span class="nx">setFooter</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span><span class="o">);</span>

		<span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">refireEvent</span><span class="o">(</span><span class="s2">&quot;iframe&quot;</span><span class="o">);</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">refireEvent</span><span class="o">(</span><span class="s2">&quot;underlay&quot;</span><span class="o">);</span>
	<span class="o">}</span> <span class="k">else</span> <span class="o">{</span> <span class="c">// Do cleanup</span>
<span class="c"></span>		<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">)</span> <span class="o">{</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span><span class="o">);</span>
			<span class="o">}</span>

			<span class="k">this</span><span class="o">.</span><span class="nx">buttonSpan</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">firstButton</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">lastButton</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">defaultHtmlButton</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">}</span>
<span class="o">};</span>


<span class="c">/**</span>
<span class="c">* The default event handler used to focus the first field of the form when the Dialog is shown.</span>
<span class="c">* @method focusFirst</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">focusFirst</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span><span class="nx">args</span><span class="o">,</span><span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
	<span class="k">if</span> <span class="o">(</span><span class="nx">args</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">var</span> <span class="nx">e</span> <span class="o">=</span> <span class="nx">args</span><span class="o">[</span><span class="m">1</span><span class="o">];</span>
		<span class="k">if</span> <span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
		<span class="o">}</span>
	<span class="o">}</span>

	<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">firstFormElement</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">firstFormElement</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
	<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">focusDefaultButton</span><span class="o">();</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Sets the focus to the last button in the button or form element in the Dialog</span>
<span class="c">* @method focusLast</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">focusLast</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span><span class="nx">args</span><span class="o">,</span><span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
	<span class="k">if</span> <span class="o">(</span><span class="nx">args</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">var</span> <span class="nx">e</span> <span class="o">=</span> <span class="nx">args</span><span class="o">[</span><span class="m">1</span><span class="o">];</span>
		<span class="k">if</span> <span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
		<span class="o">}</span>
	<span class="o">}</span>

	<span class="k">var</span> <span class="nx">buttons</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;buttons&quot;</span><span class="o">);</span>
	<span class="k">if</span> <span class="o">(</span><span class="nx">buttons</span> <span class="o">&amp;&amp;</span> <span class="nx">buttons</span> <span class="k">instanceof</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">focusLastButton</span><span class="o">();</span>
	<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
		<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">lastFormElement</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">lastFormElement</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
		<span class="o">}</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Sets the focus to the button that is designated as the default. By default, his handler is executed when the show event is fired.</span>
<span class="c">* @method focusDefaultButton</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">focusDefaultButton</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">defaultHtmlButton</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">defaultHtmlButton</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Blurs all the html buttons</span>
<span class="c">* @method blurButtons</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">blurButtons</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">var</span> <span class="nx">buttons</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;buttons&quot;</span><span class="o">);</span>
	<span class="k">if</span> <span class="o">(</span><span class="nx">buttons</span> <span class="o">&amp;&amp;</span> <span class="nx">buttons</span> <span class="k">instanceof</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">var</span> <span class="nx">html</span> <span class="o">=</span> <span class="nx">buttons</span><span class="o">[</span><span class="m">0</span><span class="o">].</span><span class="nx">htmlButton</span><span class="o">;</span>
		<span class="k">if</span> <span class="o">(</span><span class="nx">html</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">html</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>
		<span class="o">}</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Sets the focus to the first button in the button list</span>
<span class="c">* @method focusFirstButton</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">focusFirstButton</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">var</span> <span class="nx">buttons</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;buttons&quot;</span><span class="o">);</span>
	<span class="k">if</span> <span class="o">(</span><span class="nx">buttons</span> <span class="o">&amp;&amp;</span> <span class="nx">buttons</span> <span class="k">instanceof</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">var</span> <span class="nx">html</span> <span class="o">=</span> <span class="nx">buttons</span><span class="o">[</span><span class="m">0</span><span class="o">].</span><span class="nx">htmlButton</span><span class="o">;</span>
		<span class="k">if</span> <span class="o">(</span><span class="nx">html</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">html</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
		<span class="o">}</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Sets the focus to the first button in the button list</span>
<span class="c">* @method focusLastButton</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">focusLastButton</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">var</span> <span class="nx">buttons</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">cfg</span><span class="o">.</span><span class="nx">getProperty</span><span class="o">(</span><span class="s2">&quot;buttons&quot;</span><span class="o">);</span>
	<span class="k">if</span> <span class="o">(</span><span class="nx">buttons</span> <span class="o">&amp;&amp;</span> <span class="nx">buttons</span> <span class="k">instanceof</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">var</span> <span class="nx">html</span> <span class="o">=</span> <span class="nx">buttons</span><span class="o">[</span><span class="nx">buttons</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">].</span><span class="nx">htmlButton</span><span class="o">;</span>
		<span class="k">if</span> <span class="o">(</span><span class="nx">html</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">html</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span>
		<span class="o">}</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* The default event handler for the &quot;postmethod&quot; configuration property</span>
<span class="c">* @method configPostMethod</span>
<span class="c">* @param {String} type	The CustomEvent type (usually the property name)</span>
<span class="c">* @param {Object[]}	args	The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.</span>
<span class="c">* @param {Object} obj	The scope object. For configuration handlers, this will usually equal the owner.</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">configPostMethod</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">args</span><span class="o">,</span> <span class="nx">obj</span><span class="o">)</span> <span class="o">{</span>
	<span class="k">var</span> <span class="nx">postmethod</span> <span class="o">=</span> <span class="nx">args</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>

	<span class="k">this</span><span class="o">.</span><span class="nx">registerForm</span><span class="o">();</span>
	<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">,</span> <span class="s2">&quot;submit&quot;</span><span class="o">,</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
														<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
														<span class="k">this</span><span class="o">.</span><span class="nx">submit</span><span class="o">();</span>
														<span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">.</span><span class="nx">blur</span><span class="o">();</span>
													  <span class="o">},</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">// END BUILT-IN PROPERTY EVENT HANDLERS //</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c">* Built-in function hook for writing a validation function that will be checked for a &quot;true&quot; value prior to a submit. This function, as implemented by default, always returns true, so it should be overridden if validation is necessary.</span>
<span class="c">* @method validate</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">validate</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Executes a submit of the Dialog followed by a hide, if validation is successful.</span>
<span class="c">* @method submit</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">submit</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">validate</span><span class="o">())</span> <span class="o">{</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">beforeSubmitEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">doSubmit</span><span class="o">();</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">submitEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
		<span class="k">this</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
		<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
	<span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
		<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
	<span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Executes the cancel of the Dialog followed by a hide.</span>
<span class="c">* @method cancel</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">cancel</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">cancelEvent</span><span class="o">.</span><span class="nx">fire</span><span class="o">();</span>
	<span class="k">this</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Returns a JSON-compatible data structure representing the data currently contained in the form.</span>
<span class="c">* @method getData</span>
<span class="c">* @return {Object} A JSON object reprsenting the data of the current form.</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getData</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">aElements</span> <span class="o">=</span> <span class="nx">oForm</span><span class="o">.</span><span class="nx">elements</span><span class="o">,</span>
            <span class="nx">nTotalElements</span> <span class="o">=</span> <span class="nx">aElements</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
            <span class="nx">oData</span> <span class="o">=</span> <span class="o">{},</span>
            <span class="nx">sName</span><span class="o">,</span>
            <span class="nx">oElement</span><span class="o">,</span>
            <span class="nx">nElements</span><span class="o">;</span>

        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">nTotalElements</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>

            <span class="nx">sName</span> <span class="o">=</span> <span class="nx">aElements</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">name</span><span class="o">;</span>

            <span class="k">function</span> <span class="nx">isFormElement</span><span class="o">(</span><span class="nx">p_oElement</span><span class="o">)</span> <span class="o">{</span>
            
                <span class="k">var</span> <span class="nx">sTagName</span> <span class="o">=</span> <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>
                
                <span class="k">return</span> <span class="o">(</span>
                    <span class="o">(</span>
                        <span class="nx">sTagName</span> <span class="o">==</span> <span class="s2">&quot;INPUT&quot;</span> <span class="o">||</span> 
                        <span class="nx">sTagName</span> <span class="o">==</span> <span class="s2">&quot;TEXTAREA&quot;</span> <span class="o">||</span> 
                        <span class="nx">sTagName</span> <span class="o">==</span> <span class="s2">&quot;SELECT&quot;</span>
                    <span class="o">)</span> <span class="o">&amp;&amp;</span> 
                    <span class="nx">p_oElement</span><span class="o">.</span><span class="nx">name</span> <span class="o">==</span> <span class="nx">sName</span>
                <span class="o">);</span>

            <span class="o">}</span>

            <span class="c">/*</span>
<span class="c">                Using &quot;YAHOO.util.Dom.getElementsBy&quot; to safeguard</span>
<span class="c">                user from JS errors that result from giving a form field (or </span>
<span class="c">                set of fields) the same name as a native method of a form </span>
<span class="c">                (like &quot;submit&quot;) or a DOM collection (such as the &quot;item&quot; method).</span>
<span class="c">                Originally tried accessing fields via the &quot;namedItem&quot; method of </span>
<span class="c">                the &quot;element&quot; collection, but discovered that it won&#39;t return</span>
<span class="c">                a collection of fields in Gecko.</span>
<span class="c">            */</span>

            <span class="nx">oElement</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsBy</span><span class="o">(</span><span class="nx">isFormElement</span><span class="o">,</span> <span class="s2">&quot;*&quot;</span><span class="o">,</span> <span class="nx">oForm</span><span class="o">);</span>
            <span class="nx">nElements</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>

            <span class="k">if</span><span class="o">(</span><span class="nx">nElements</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

                <span class="k">if</span><span class="o">(</span><span class="nx">nElements</span> <span class="o">==</span> <span class="m">1</span><span class="o">)</span> <span class="o">{</span>

                    <span class="nx">oElement</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>

                    <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">type</span><span class="o">,</span>
                        <span class="nx">sTagName</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">();</span>

                    <span class="nx">switch</span><span class="o">(</span><span class="nx">sTagName</span><span class="o">)</span> <span class="o">{</span>

                        <span class="nx">case</span> <span class="s2">&quot;INPUT&quot;</span><span class="o">:</span>

                            <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">)</span> <span class="o">{</span>

                                <span class="nx">oData</span><span class="o">[</span><span class="nx">sName</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">checked</span><span class="o">;</span>

                            <span class="o">}</span>
                            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">sType</span> <span class="o">!=</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>

                                <span class="nx">oData</span><span class="o">[</span><span class="nx">sName</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>

                            <span class="o">}</span>

                        <span class="k">break</span><span class="o">;</span>

                        <span class="nx">case</span> <span class="s2">&quot;TEXTAREA&quot;</span><span class="o">:</span>

                            <span class="nx">oData</span><span class="o">[</span><span class="nx">sName</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>

                        <span class="k">break</span><span class="o">;</span>

                        <span class="nx">case</span> <span class="s2">&quot;SELECT&quot;</span><span class="o">:</span>

                            <span class="k">var</span> <span class="nx">aOptions</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">.</span><span class="nx">options</span><span class="o">,</span>
                                <span class="nx">nOptions</span> <span class="o">=</span> <span class="nx">aOptions</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
                                <span class="nx">aValues</span> <span class="o">=</span> <span class="o">[],</span>
                                <span class="nx">oOption</span><span class="o">,</span>
                                <span class="nx">sValue</span><span class="o">;</span>


                            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">n</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">n</span><span class="o">&lt;</span><span class="nx">nOptions</span><span class="o">;</span> <span class="nx">n</span><span class="o">++)</span> <span class="o">{</span>

                                <span class="nx">oOption</span> <span class="o">=</span> <span class="nx">aOptions</span><span class="o">[</span><span class="nx">n</span><span class="o">];</span>

                                <span class="k">if</span><span class="o">(</span><span class="nx">oOption</span><span class="o">.</span><span class="nx">selected</span><span class="o">)</span> <span class="o">{</span>

                                    <span class="nx">sValue</span> <span class="o">=</span> <span class="nx">oOption</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>

                                    <span class="k">if</span><span class="o">(!</span><span class="nx">sValue</span> <span class="o">||</span> <span class="nx">sValue</span> <span class="o">===</span> <span class="s2">&quot;&quot;</span><span class="o">)</span> <span class="o">{</span>

                                        <span class="nx">sValue</span> <span class="o">=</span> <span class="nx">oOption</span><span class="o">.</span><span class="nx">text</span><span class="o">;</span>

                                    <span class="o">}</span>

                                    <span class="nx">aValues</span><span class="o">[</span><span class="nx">aValues</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">sValue</span><span class="o">;</span>

                                <span class="o">}</span>

                            <span class="o">}</span>

                            <span class="nx">oData</span><span class="o">[</span><span class="nx">sName</span><span class="o">]</span> <span class="o">=</span> <span class="nx">aValues</span><span class="o">;</span>

                        <span class="k">break</span><span class="o">;</span>

                    <span class="o">}</span>


                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>

                    <span class="k">var</span> <span class="nx">sType</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">[</span><span class="m">0</span><span class="o">].</span><span class="nx">type</span><span class="o">;</span>

                    <span class="nx">switch</span><span class="o">(</span><span class="nx">sType</span><span class="o">)</span> <span class="o">{</span>

                        <span class="nx">case</span> <span class="s2">&quot;radio&quot;</span><span class="o">:</span>

                            <span class="k">var</span> <span class="nx">oRadio</span><span class="o">;</span>

                            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">n</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">n</span><span class="o">&lt;</span><span class="nx">nElements</span><span class="o">;</span> <span class="nx">n</span><span class="o">++)</span> <span class="o">{</span>

                                <span class="nx">oRadio</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">[</span><span class="nx">n</span><span class="o">];</span>

                                <span class="k">if</span><span class="o">(</span><span class="nx">oRadio</span><span class="o">.</span><span class="nx">checked</span><span class="o">)</span> <span class="o">{</span>

                                    <span class="nx">oData</span><span class="o">[</span><span class="nx">sName</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oRadio</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>
                                    <span class="k">break</span><span class="o">;</span>

                                <span class="o">}</span>

                            <span class="o">}</span>

                        <span class="k">break</span><span class="o">;</span>

                        <span class="nx">case</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">:</span>

                            <span class="k">var</span> <span class="nx">aValues</span> <span class="o">=</span> <span class="o">[],</span>
                                <span class="nx">oCheckbox</span><span class="o">;</span>

                            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">n</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">n</span><span class="o">&lt;</span><span class="nx">nElements</span><span class="o">;</span> <span class="nx">n</span><span class="o">++)</span> <span class="o">{</span>

                                <span class="nx">oCheckbox</span> <span class="o">=</span> <span class="nx">oElement</span><span class="o">[</span><span class="nx">n</span><span class="o">];</span>

                                <span class="k">if</span><span class="o">(</span><span class="nx">oCheckbox</span><span class="o">.</span><span class="nx">checked</span><span class="o">)</span> <span class="o">{</span>

                                    <span class="nx">aValues</span><span class="o">[</span><span class="nx">aValues</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oCheckbox</span><span class="o">.</span><span class="nx">value</span><span class="o">;</span>

                                <span class="o">}</span>

                            <span class="o">}</span>

                            <span class="nx">oData</span><span class="o">[</span><span class="nx">sName</span><span class="o">]</span> <span class="o">=</span> <span class="nx">aValues</span><span class="o">;</span>

                        <span class="k">break</span><span class="o">;</span>

                    <span class="o">}</span>

                <span class="o">}</span>

            <span class="o">}</span>

        <span class="o">}</span>

    <span class="o">}</span>


    <span class="k">return</span> <span class="nx">oData</span><span class="o">;</span>

<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Removes the Panel element from the DOM and sets all child elements to null.</span>
<span class="c">* @method destroy</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">destroy</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>

    <span class="k">var</span> <span class="nx">Event</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">,</span>
        <span class="nx">oForm</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">form</span><span class="o">,</span>
        <span class="nx">oFooter</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">footer</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oFooter</span><span class="o">)</span> <span class="o">{</span>

        <span class="k">var</span> <span class="nx">aButtons</span> <span class="o">=</span> <span class="nx">oFooter</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="s2">&quot;button&quot;</span><span class="o">);</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">aButtons</span> <span class="o">&amp;&amp;</span> <span class="nx">aButtons</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>

            <span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">aButtons</span><span class="o">.</span><span class="nx">length</span> <span class="o">-</span> <span class="m">1</span><span class="o">;</span>
            
            <span class="k">do</span> <span class="o">{</span>
            
                <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">aButtons</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="kc">false</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">);</span>
            
            <span class="o">}</span>
            <span class="k">while</span><span class="o">(</span><span class="nx">i</span><span class="o">--);</span>
        
        <span class="o">}</span>

    <span class="o">}</span>
    

    <span class="k">if</span><span class="o">(</span><span class="nx">oForm</span><span class="o">)</span> <span class="o">{</span>
       
        <span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="nx">oForm</span><span class="o">);</span>

        <span class="k">this</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">removeChild</span><span class="o">(</span><span class="nx">oForm</span><span class="o">);</span>
        
        <span class="k">this</span><span class="o">.</span><span class="nx">form</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

    <span class="o">}</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">destroy</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>  

<span class="o">};</span>

<span class="c">/**</span>
<span class="c">* Returns a string representation of the object.</span>
<span class="c">* @method toString</span>
<span class="c">* @return {String}	The string representation of the Dialog</span>
<span class="c">*/</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Dialog</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">toString</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
	<span class="k">return</span> <span class="s2">&quot;Dialog &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
<span class="o">};</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class=""><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class=""><a href="module_connection.html">connection</a></li>

                                <li class="selected"><a href="module_container.html">container</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class=""><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class=""><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="YAHOO.util.Config.html">YAHOO.util.Config</a></li>
                                <li class=""><a href="YAHOO.widget.ContainerEffect.html">YAHOO.widget.ContainerEffect</a></li>
                                <li class=""><a href="YAHOO.widget.Dialog.html">YAHOO.widget.Dialog</a></li>
                                <li class=""><a href="YAHOO.widget.Module.html">YAHOO.widget.Module</a></li>
                                <li class=""><a href="YAHOO.widget.Overlay.html">YAHOO.widget.Overlay</a></li>
                                <li class=""><a href="YAHOO.widget.OverlayManager.html">YAHOO.widget.OverlayManager</a></li>
                                <li class=""><a href="YAHOO.widget.Panel.html">YAHOO.widget.Panel</a></li>
                                <li class=""><a href="YAHOO.widget.SimpleDialog.html">YAHOO.widget.SimpleDialog</a></li>
                                <li class=""><a href="YAHOO.widget.Tooltip.html">YAHOO.widget.Tooltip</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="Config.js.html">Config.js</a></li>
                                <li class=""><a href="ContainerEffect.js.html">ContainerEffect.js</a></li>
                                <li class="selected"><a href="Dialog.js.html">Dialog.js</a></li>
                                <li class=""><a href="Module.js.html">Module.js</a></li>
                                <li class=""><a href="Overlay.js.html">Overlay.js</a></li>
                                <li class=""><a href="OverlayManager.js.html">OverlayManager.js</a></li>
                                <li class=""><a href="Panel.js.html">Panel.js</a></li>
                                <li class=""><a href="SimpleDialog.js.html">SimpleDialog.js</a></li>
                                <li class=""><a href="Tooltip.js.html">Tooltip.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
